package com.qf.controller;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @version v1.0.0
 * @Description:
 * @author: 赵英杰
 * @date: 2022.02.14
 * @since 1.0
 */
@Component
public class MyHandlerException implements HandlerExceptionResolver {

    /**
     *
     * @param request 请求对象
     * @param response 响应对象
     * @param handler 出现异常的后端控制器（controller）
     * @param ex 捕获的异常对象
     * @return
     */
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        ModelAndView mva = new ModelAndView();
        mva.setViewName("error");

        return mva ;
    }
}
